package com.yh.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Calendar;
import java.util.Map;

public class LookPtor extends AbstractInterceptor {


    @Override
    public String intercept(ActionInvocation act) throws Exception {
        Calendar cale=Calendar.getInstance();
        ActionContext atx= act.getInvocationContext();
        Map request = (Map) atx.get("request");
        int curr=cale.get(Calendar.HOUR_OF_DAY);
        if(curr>1&&curr<3){
           request.put("msg","<h2>页面维护中无法浏览,请<a href='javascript:history.go(-1)'>返回</a></h2>");
            return "error";
        }else{
            return act.invoke();
        }
    }
}
